<?php

declare(strict_types=1);

namespace app\admin\controller;

use addons\Builder\facade\Builder;
//该文件为自动生成，请按需修改
class Deal extends Base
{
    //主键，默认为id
    protected string $pk = 'id';

    //主模型
    protected string $model = '\app\common\model\Deal';
    //关联模型
    protected array $hasOne = ['user'];

    protected array $append = ['statusText', 'typeText'];
    public function index(): string
    {
        $search = [
            ['uid', '会员编号/昵称', 'input', '', '\app\common\model\User', 'code|nickname|mobile,id'],
            ['status', '状态', 'select', $this->model::getDealStatus('', 2)],
            ['type', '交易类型', 'select', $this->model::getDealType('', 2)],
        ];
        return Builder::Table()
            ->autoStructure($this->model, $this->pk, 'barDemo,200')
            ->addRightButtons([
                'recharge' => [
                    'title' => '交易详情',
                    'icon' => 'layui-icon-util',
                    'url'   => url('dealOrder/index')->build(),
                    'event' => '_openNewPage',
                    'size'  => '100%'
                ],
            ])
            ->addSearch($search)
            ->fetch();
    }
}
